<?php
$smarty->configLoad($lang . '/petitions.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$_language = parse_ini_file($lang . '/petitions.module.php', true);
$breadcrumb = $language['petitions'];
$sql = 'SELECT * FROM '.DB_GAME.'.petitions WHERE status = "IN_PROGRESS" OR status = "PENDING"';
$dbh = $connection->prepare($sql);
$dbh->execute();
$value = '';
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	if($row['status'] == 'PENDING') {
		$row['status'] = $_language['PENDING'];
	} elseif($row['status'] == 'REPLIED') {
		$row['status'] = $_language['REPLIED'];
	} elseif($row['status'] == 'IN_PROGRESS') {
		$row['status'] = $_language['IN_PROGRESS'];
	}
	$value[] = $row;

}
$smarty->assign('value', $value);

$sql = 'SELECT * FROM '.DB_GAME.'.petitions WHERE status = "REPLIED"';
$dbh = $connection->prepare($sql);
$dbh->execute();
$value_old = '';
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	if($row['status'] == 'PENDING') {
		$row['status'] = $_language['PENDING'];
	} elseif($row['status'] == 'REPLIED') {
		$row['status'] = $_language['REPLIED'];
	} elseif($row['status'] == 'IN_PROGRESS') {
		$row['status'] = $_language['IN_PROGRESS'];
	}
	$old_value[] = $row;

}
$smarty->assign('old_value', $old_value);
$template = 'petitions/index.tpl';
?>
